package com.zhongshan.ga.mybatis.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhongshan.ga.mybatis.bean.LoginWayInfo;
import com.zhongshan.ga.mybatis.bean.PeopleInfoBean;
import com.zhongshan.ga.mybatis.bean.UserHeadImg;

/**
 * 登陆信息数据访问接口
 * @author kakaxi
 *
 */
public interface ILoginWayInfoDao {
	
	/**
	 * 添加登陆信息
	 * @param loginWayInfo 登陆信息类
	 * @return
	 */
	@Insert("INSERT INTO loginwayinfo (id, PeopleSystemCode, QQLoginId, WeChatLoginID,"
			+ " WeiboLoginID, EmailLoginID, PhoneLoginID, FaceBookLoginID, IsActivity) "
			+ " VALUES (0, #{peopleSystemCode}, #{qQLoginId}, #{weChatLoginID},"
			+ " #{weiboLoginID}, #{emailLoginID}, #{phoneLoginID}, #{faceBookLoginID},"
			+ " #{isActivity})")
	public int addLoginWayInfo(LoginWayInfo loginWayInfo);

	
//	/**
//	 * 更新用户信息
//	 * @param peopleInfo 
//	 * @return
//	 */
//	@Update("UPDATE peopleInfo SET NAME=#{name}, Sex=#{sex}, Age=#{sex}, Address=#{address}, "
//			+ "PhoneNumber=#{phoneNumber}, Birthday=#{birthday}, SecondPhoneNum=#{secondPhoneNum},"
//			+ " Email=#{email}, IsVip=#{isVip}, InnermostWords=#{innermostWords}, "
//			+ "NickName=#{nickName} where PeopleSystemCode=#{peopleSystemCode}")
//	public int updatePeopleInfo(PeopleInfo peopleInfo);
	
	/**
	 * 获取所有登陆信息
	 * @return
	 */
	@Select("select * from loginwayinfo")
	public List<LoginWayInfo> getAllLoginWayInfo();
	
	/**
	 * 根据登陆编码获取登陆信息
	 * @param id 登陆编码
	 * @return
	 */
	@Select("select * from loginwayinfo where id=#{id}")
	public PeopleInfoBean getLoginWayInfoById(String id);
	
	/**
	 * 根据qqid获取登陆信息
	 * @param qqLoginId
	 * @return
	 */
	@Select("select * from loginwayinfo where QQLoginId=#{qqLoginId}")
	public LoginWayInfo getLoginWayInfoByQQ(String qqLoginId);
	
	/**
	 * 根据微博id获取登陆信息
	 * @param weiboLoginID
	 * @return
	 */
	@Select("select * from loginwayinfo where WeChatLoginID=#{weiboLoginID}")
	public LoginWayInfo getLoginWayInfoByWeibo(String weiboLoginID);
	
	/**
	 * 根据微信id获取登陆信息
	 * @param weChatLoginID
	 * @return
	 */
	@Select("select * from loginwayinfo where WeChatLoginID=#{weChatLoginID}")
	public LoginWayInfo getLoginWayInfoByWechat(String weChatLoginID);

	/**
	 * 根据邮件id获取登陆信息
	 * @param emailLoginID
	 * @return
	 */
	@Select("select * from loginwayinfo where EmailLoginID=#{emailLoginID}")
	public LoginWayInfo getLoginWayInfoByEmail(String emailLoginID);
	
	/**
	 * 根据手机id获取登陆信息
	 * @param phoneLoginID
	 * @return
	 */
	@Select("select * from loginwayinfo where PhoneLoginID=#{phoneLoginID}")
	public LoginWayInfo getLoginWayInfoByPhone(String phoneLoginID);
	
	/**
	 * 根据facebook id获取登陆信息
	 * @param faceBookLoginID
	 * @return
	 */
	@Select("select * from loginwayinfo where FaceBookLoginID=#{faceBookLoginID}")
	public LoginWayInfo getLoginWayInfoByFaceBook(String faceBookLoginID);
	
	/**
	 * 添加头像信息
	 * @param userHeadImg 头像信息类
	 * @return
	 */
	@Insert("INSERT INTO userheadimg (PeopleSystemCode, HeadID, HeadImgUrl, IsActivity) "
			+ " VALUES (#{peopleSystemCode}, 0, #{headImgUrl}, 1)")
	public int addUserHeadImg(UserHeadImg userHeadImg);
	
	/**
	 * 更新
	 * @param peopleSystemCode
	 * @return
	 */
	@Update("UPDATE userheadimg SET userheadimg.`IsActivity`=0 WHERE userheadimg.`PeopleSystemCode`=#{peopleSystemCode} ")
	public int updateUserHeadImg(String peopleSystemCode);
	
	/**
	 * 获取头像
	 * @param peopleSystemCode
	 * @return
	 */
	@Select("select * from userheadimg where PeopleSystemCode=#{peopleSystemCode} and isActivity=1")
	public UserHeadImg getUserHeadImg(String peopleSystemCode);
	
}
